package day0318.biginteger;

import java.math.BigInteger;

/**
 * @Author Stringzhua
 * @Date 2024/3/18 16:42
 * description:BigInteger使用
 */
public class BigInteger_ {
    public static void main(String[] args) {
//        BigInteger bg = new BigInteger();
//        System.out.println(String.valueOf(bg));
//        System.out.println(bg.toString());
        BigInteger bg = new BigInteger("127");
        System.out.println(bg);
        System.out.println(bg.pow(2));

        System.out.println("=======");
        System.out.println(bg.longValue());//如果数字超过其取值范围,则溢出
        System.out.println(bg.longValueExact());//如果数字超过其取值范围，则报异常
        System.out.println(bg.byteValue());
        System.out.println(bg.byteValueExact());
        System.out.println(bg.intValue());
        System.out.println(bg.intValueExact());

        BigInteger a1 = new BigInteger("2");
        BigInteger a2 = new BigInteger("4");

        System.out.println("加"+a1.add(a2));
        System.out.println("减"+a1.subtract(a2));
        System.out.println("乘" + a1.multiply(a2));
        System.out.println("除"+a1.divide(a2));
    }
}
